package com.wing.bill.controller.admin;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.bill.service.CabinetFormService;
import com.wing.bill.service.CostCenterService;
import com.wing.cabinet.model.response.CellInventoryInoutVO;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.web.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Validated
@Api(value = "Admin-成本中心报表", tags = "#/bill/costCenter")
@RestController("costCenterController")
@RequestMapping("bill/admin/costCenter")
@RequiredArgsConstructor
public class CostCenterController {

    private final CostCenterService costCenterService;

    /**
     * @param param 数量 money金额
     * @return
     */
    @ApiOperation(value = "顶部折线图", notes = "搜索")
    @GetMapping("/list")
    public JsonResult list(@RequestParam("param")String param,@RequestParam(value = "costCenter",required = false)String costCenter
            ,@RequestParam(value = "startTime",required = false)String startTime
            ,@RequestParam(value = "endTime",required = false)String endTime){

        return costCenterService.list(param,JwtUtils.getEnterpriseCode(),costCenter,startTime,endTime);
    }
    @ApiOperation(value = "按成本中心统计人数", notes = "搜索")
    @GetMapping("/costCenterBodyCount")
    public JsonResult costCenterBodyCount(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterBodyCount(type,startTime,endTime,param,JwtUtils.getEnterpriseId(),costCenter);
    }

    @ApiOperation(value = "谁领的最多", notes = "搜索")
    @GetMapping("/costCenterGetMuch")
    public JsonResult costCenterGetMuch(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterGetMuch(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter);
    }
    @ApiOperation(value = "消耗规格最多", notes = "搜索")
    @GetMapping("/costCenterConsumeMuch")
    public JsonResult costCenterConsumeMuch(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterConsumeMuch(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter);
    }
    @ApiOperation(value = "谁报修最多", notes = "搜索")
    @GetMapping("/costCenterCcrap")
    public JsonResult costCenterCcrap(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterScrap(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter,2);
    }
    @ApiOperation(value = "谁报废最多", notes = "搜索")
    @GetMapping("/costCenterScrappage")
    public JsonResult costCenterScrappage(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterScrap(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter,3);
    }
    @ApiOperation(value = "谁报失最多", notes = "搜索")
    @GetMapping("/costCenterLost")
    public JsonResult costCenterLost(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterLost(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter,7);
    }
    @ApiOperation(value = "盘验异常排名（按成本中心）", notes = "搜索")
    @GetMapping("/costCenterCheck")
    public JsonResult costCenterCheck(
            @RequestParam("type")String type//012 当日当周当月
            ,@RequestParam("startTime")String startTime//时间搜索 开始时间
            ,@RequestParam("endTime")String endTime//时间搜索 结束时间
            ,@RequestParam("param")String param //柱状图饼状图的下拉选 不同的选项 qua 数量 money 金额
            ,@RequestParam("costCenter") String costCenter //成本中心选择
    ){
        return costCenterService.costCenterCheck(type,startTime,endTime,param,JwtUtils.getEnterpriseCode(),costCenter);
    }



}
